<?php
include 'checa_login.php';
include 'header.php';
include 'menu.php';

$sql = "SELECT * from usuario";

$query = mysql_query($sql, $conecta) or die(mysql_error());

$linha = mysql_fetch_assoc($query);

$total = mysql_num_rows($query);
?>
<div class="container" style="margin-top: 80px;">
    <div class="row">
            <div class="col-md-8 col-md-offset-2">
                <div class="panel panel-default">
                 <div class="panel-heading">
                        <h4 class="panel-title"><span class="glyphicon glyphicon-user"></span>&nbsp;Usuários</h4>
                    </div>
                <br>
                <div class="panel-body">
                    <div class="table-responsive">
                <table id="example" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
                    <thead>
                        <tr >
                            <th class="text-center">ID</th>
                            <th class="text-center">Nome</th>
                            <th class="text-center">Login</th>
                            <th class="text-center"></th>
                            <th class="text-center"></th>
                        </tr>
                    </thead>

                    <tbody>
<?php if ($total > 0) {
    do {
        ?> 
                                <tr>
                                    <td class="text-center">
                                        <?= $linha['cd_usuario'] ?>
                                    </td>
                                    <td class="text-center">
                                        <?= $linha['nome_usuario'] ?>
                                    </td>
                                    <td class="text-center">
                                        <?= $linha['login_usuario'] ?>
                                    </td>
                                    <td class="text-center">
                                        <a><i class="fa fa-pencil-square-o" style="font-size: 30px;"></i></a>
                                    </td>
                                    <td class="text-center">
                                        <a><i class="fa fa-times" style="font-size: 25px;"></i></a>
                                    </td>
                                    
                                </tr>
                            <?php
                            } while ($linha = mysql_fetch_assoc($query));
                        }
                        ?>
                    </tbody>
                </table>
                    </div>
                </div>
            </div>
                 <div class="col-md-2 col-md-offset-10">
                     <button id="btn_novo" class="btn btn-primary" onclick="javascript:window.location='novo_usuario.php'">Novo</button> 
         </div>
        </div>
    </div>
<?php
include 'footer.php';
?>
